package com.sne.airways.system.controller;

import com.sne.airways.basecore.controller.BaseController;
import com.sne.airways.system.dto.TdRoleCheckDTO;
import com.sne.airways.system.service.RoleService;
import com.sne.airways.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 12-12-14
 * Time: 下午5:50
 * To change this template use File | Settings | File Templates.
 */
@Controller
@RequestMapping("/system/userrole")
public class UserRoleController extends BaseController{

    @Autowired
    private RoleService roleService;

    @RequestMapping("/queryRoleCheckedList")
    @ResponseBody
    public void queryUserList(String userId){
        List<String> roleIdList = roleService.queryRoleCheckedList(userId);
        renderJsonArray(roleIdList);
    }


    @RequestMapping("/saveUserRole")
    @ResponseBody
    public void saveUserRole(String userId,@RequestParam(required = false) String[] ids){
        roleService.saveUserRole(userId,ids);
        renderSuccess();
    }
}
